#include "gofgame/jumpdown/MainScene.h"
#include "gofgame/jumpdown/layer/MenuLayer.h"
#include "SimpleAudioEngine.h"

using namespace gofgame::jumpdown;
using namespace gofgame::jumpdown::layer;
using namespace CocosDenshion;

bool MainScene::init() {
	if (!CCScene::init()) {
		delete this;
		return false;
	}
	initOption();
	MenuLayer* menuLayer = MenuLayer::createMenuLayer();
	this->addChild(menuLayer);
	return true;
}

void MainScene::initOption() {
	bool enableSound = CCUserDefault::sharedUserDefault()->getBoolForKey("enableSound",true);
	if(!enableSound) {
		SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.0f);
	} else {
		SimpleAudioEngine::sharedEngine()->setEffectsVolume(1.0f);
	}
}

MainScene* MainScene::createMainScene(){
	MainScene* ms = new MainScene();
	if (ms->init()) {
		ms->autorelease();
		return ms;
	}
	return nullptr;
}